package com.example.androidshixi;

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.List;

public class MyOrdersActivity extends AppCompatActivity {
    private ListView orderListView;
    private List<String> myOrderList;
    private UserSessionManager sessionManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_orders);

        orderListView = findViewById(R.id.order_list_view);
        sessionManager = new UserSessionManager(this);
        myOrderList = new ArrayList<>();

        // 模拟从购物车获取当前用户的订单列表
        List<Product> cartItems = ShoppingCart.getInstance().getCartItems();
        for (Product product : cartItems) {
            myOrderList.add("商品: " + product.getName() + "，价格: ￥" + product.getPrice());
        }

        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, myOrderList);
        orderListView.setAdapter(adapter);
    }
}